package com.film.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.film.domain.FilmOrder;
import com.film.domain.UserOrder;
import com.film.service.OrderService;
import com.film.service.impl.OrderServiceImpl;

@WebServlet("/currentOrder")
public class PayCurrentController extends HttpServlet{
	
	private OrderService orderService = new OrderServiceImpl();
	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String orderNum = request.getParameter("orderNum");
		List<FilmOrder> currentOrders = orderService.selectOrder(orderNum);
		List<UserOrder> currOrders = orderService.arrangeList(currentOrders);
		HttpSession session = request.getSession();
		session.setAttribute("currOrders", currOrders);
		response.sendRedirect("pay.jsp");
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doGet(req, resp);
	}
}
